package com.flea.hclv.controller;

import com.flea.hclv.model.entity.HTicketSellOrder;
import com.flea.hclv.service.HTicketSellOrderService;
import com.flea.hclv.util.ServerResponse;
import com.flea.system.bean.FleaPage;
import com.flea.system.entity.OrgDept;
import com.flea.system.platform.session.FleaOrgUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @program: project
 * @description: 组团社销售门票记录
 * @author: shiliqiang
 * @create: 2018-12-31 15:08
 * @version: 1.0
 */
@Controller
@RequestMapping("/flea/hclv/ticket/sell/order")
public class HTicketSellOrderController {

    @Autowired
    private HTicketSellOrderService hTicketSellOrderService;

    @RequestMapping("createSellOrder")
    @ResponseBody
    public ServerResponse<String> createVisitorOrder(HttpServletRequest request,String model) throws Exception {
        String userId = FleaOrgUtils.getCurUserUuid(request);
        OrgDept currentUserDept = FleaOrgUtils.getCurrentUserDept(request);
        if (currentUserDept==null){
            return ServerResponse.createByErrorMessage("部门信息不能为空");
        }
        return hTicketSellOrderService.saveSellOrder(model,userId,currentUserDept.getDeptUuid());
    }
    //游客门票订单列表
    @RequestMapping("selectSellOrderInfo")
    @ResponseBody
    public ServerResponse<FleaPage<HTicketSellOrder>> selectSellOrderInfo(HttpServletRequest request, FleaPage paging,
                                                                          @RequestParam(value = "spotName", defaultValue = "") String spotName){
//        String userId = FleaOrgUtils.getCurUserUuid(request);ab
        OrgDept currentUserDept = FleaOrgUtils.getCurrentUserDept(request);
        if (currentUserDept==null){
            return ServerResponse.createByErrorMessage("部门信息不能为空");
        }
        return hTicketSellOrderService.selectSellOrderInfo(paging.getCurPage(),paging.getPageSize(),currentUserDept.getDeptUuid(),spotName);
    }
    //游客门票订单详情
    @RequestMapping("selectSellOrderItemInfo")
    @ResponseBody
    public ServerResponse<Map<String,Object>> selectSellOrderItemInfo(HttpServletRequest request, String orderId){
//        String userId = FleaOrgUtils.getCurUserUuid(request);
        OrgDept currentUserDept = FleaOrgUtils.getCurrentUserDept(request);
        if (currentUserDept==null){
            return ServerResponse.createByErrorMessage("部门信息不能为空");
        }
        return hTicketSellOrderService.selectSellOrderItemInfo(orderId);
    }



}
